home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / web_dev / files / jext-install.exe / {app} / bin / jext.js < prev    next >
Encoding:
JavaScript  |  2001-06-19  |  2.7 KB  |  94 lines

  1. //////////////////////////////////////////////////////////
  2. // jext.js - Script to start Jext under Windows 98
  3. // 01/05/2001 - 01:22:45
  4. // v1.4
  5. //
  6. // I know I shouldn't have made thos ugly nested tries
  7. //
  8. // JScript for starting Jext on Win98 or Win95 + WSH
  9. // This script first checks existance of an installed JRE,
  10. // then it checks existance of Jext archive. If one is not
  11. // found, we exit and please user to download either Jext
  12. // either a JRE.
  13. //
  14. // www.jext.org
  15. // romain.guy@jext.org
  16.  
  17. // Set objects
  18. var fileSystem = WScript.createObject("Scripting.FileSystemObject");
  19. var shell = WScript.createObject("WScript.Shell");
  20.  
  21. function noJDK()
  22. {
  23.   shell.popup("You have no valid JDK/JRE installed\nPlease download one at:\n" +
  24.               "http://java.sun.com", 0, "Jext", 16);
  25.   WScript.quit(1);
  26. }
  27.  
  28. /////////////////////////////////////////////////////////////////////////////////////////////////
  29. // EXISTANCE TEST
  30. /////////////////////////////////////////////////////////////////////////////////////////////////
  31.  
  32. // Get JDK release
  33. var javaVersion;
  34.  
  35. // trying with a JRE
  36. try
  37. {
  38.   javaVersion = shell.regRead("HKLM\\Software\\JavaSoft\\Java Runtime Environment\\CurrentVersion");
  39. } catch (Exception) {
  40.   // trying with a JDK
  41.   try
  42.   {
  43.     javaVersion = shell.regRead("HKLM\\Software\\JavaSoft\\Java Development Kit\\CurrentVersion");
  44.   } catch (Exception) {
  45.     noJDK();
  46.   }
  47. }
  48.  
  49. if (javaVersion.substring(0, 3) == "1.1")
  50. {
  51.   shell.popup("This script is targeted to be used\nwith a JDK 1.2 or greater only !",
  52.               0, "Jext", 16);
  53.   WScript.quit(1);
  54. }
  55.  
  56. // Get path to JVM (here it is a JRE which is requested)
  57. var javaPath;
  58.  
  59. try
  60. {
  61.   javaPath = shell.regRead("HKLM\\Software\\JavaSoft\\Java Runtime Environment\\" + javaVersion +
  62.                            "\\JavaHome") + "\\bin\\javaw.exe";
  63. } catch (Exception) {
  64.   try
  65.   {
  66.     javaPath = shell.regRead("HKLM\\Software\\JavaSoft\\Java Development Kit\\" + javaVersion +
  67.                              "\\JavaHome") + "\\bin\\javaw.exe";
  68.   } catch (Exception) {
  69.     noJDK();
  70.   }
  71. }
  72.  
  73. // Check existance of JRE
  74. if (!fileSystem.fileExists(javaPath))
  75. {
  76.   noJDK();
  77. }
  78.  
  79. /////////////////////////////////////////////////////////////////////////////////////////////////
  80. // RUNNING STAGE
  81. /////////////////////////////////////////////////////////////////////////////////////////////////
  82.  
  83. // We concat arguments
  84. var args = WScript.arguments;
  85. var argString = new String;
  86.  
  87. for (i = 0; i < args.count(); i++)
  88.   argString = argString + ' ' + '\"' +  args.item(i) + '\"';
  89.  
  90. // Run Jext
  91. shell.run('\"' + javaPath + '\"' + " -Xmx32m -Xincgc -classpath ..\\lib\\jext.jar;..\\lib\\skinlf.jar org.jext.Jext" + argString);
  92.  
  93. // End of jext.js
  94.